//
//  FirestPageViewController.m
//  TTMusic
//
//  Created by yanghuiyan on 16/4/14.
//  Copyright © 2016年 cpy. All rights reserved.
//

#import "FirestPageViewController.h"
#import "ViewController.h"
#import "TTMusicLeftPageViewController.h"
#import "LeftSlideViewController.h"
@interface FirestPageViewController ()<UIScrollViewDelegate>

@property (nonatomic, strong) UIScrollView *firstScrollView;

@property (nonatomic, strong) NSArray *picArray;

@property (nonatomic, strong) UINavigationController *nav;

@property (nonatomic, strong) ViewController * VC;

@property (nonatomic, strong) LeftSlideViewController *LeftSlideVC;

@property (nonatomic, strong) TTMusicPlayBottomView *bottomView;


@end

@implementation FirestPageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor colorWithRed:arc4random()%255/255.0 green:arc4random()%255/255.0 blue:arc4random()%255/255.0 alpha:1];
    
    self.firstScrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    
    self.firstScrollView.contentSize = CGSizeMake(SysWidth * 4, 0);
    
    self.firstScrollView.contentOffset = CGPointMake(0, 0);
    
    self.firstScrollView.pagingEnabled = YES;
    
    self.firstScrollView.delegate = self;

    _picArray = @[@"a",@"b",@"c",@"d"];
    
    for (int i = 0; i < _picArray.count; i++) {
        
        UIImageView *backImage = [[UIImageView alloc] initWithFrame:CGRectMake(SysWidth * i, 0, SysWidth, SysHeight)];
        
        backImage.image = [UIImage imageNamed:_picArray[i]];
        
        [self.firstScrollView addSubview:backImage];
        
    }
    
    [self.view addSubview:self.firstScrollView];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    [button setFrame:CGRectMake(330, 30, 40, 40)];
    [button setTitle:@"跳过" forState:UIControlStateNormal];
    button.layer.cornerRadius = 20;
    button.backgroundColor = [UIColor grayColor];
    [button addTarget:self action:@selector(JumpAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    
}

- (void)JumpAction {
    

    [self.jumpDelegate welcomeJump];

    
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    if (scrollView.contentOffset.x > (_picArray.count - 1) * SysWidth) {
        [self JumpAction];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
